
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>新增角色</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link href="css/style.winning.css?v=1.0.0" rel="stylesheet">
</head>
<body>
<div class="col-sm-6">
    <div class="ibox-content">
        <form class="form-horizontal m-t" id="roleForm">
            <div class="form-group">
                <input type="hidden" id="jgbm" name="jgbm"/>
                <label class="col-sm-4 control-label">
                    <span class="label-required-wn">*</span>角色名称：</label>
                <div class="col-sm-3">
                    <input id="jsmc" name="jsmc" maxlength="32" minlength="2" type="text" class="form-control input-mb" required="" aria-required="true">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-4 control-label">
                    角色描述：</label>
                <div class="col-sm-3">
                    <input id="jsms" name="jsms" maxlength="64" minlength="2" type="text" class="form-control" required="" aria-required="true">
                </div>
            </div>

            <div class="form-group" style="text-align: right;margin-top: 55px">
                <div class="col-sm-4 col-sm-offset-3">
                    <button class="btn btn-primary-wn" type="button" onclick="save();">保存</button>
                </div>
            </div>
        </form>
    </div>

</div>
<script type="text/javascript" src="js/jquery.min.js?v=3.5.1"></script>
<script type="text/javascript" src="js/bootstrap.min.js?v=3.3.6"></script>
<script type="text/javascript" src="js/plugins/layer/layer.min.js"></script>
<script type="text/javascript" src="platcommon/layer-wn.js?v=1.0.0"></script>
<script type="text/javascript" src="platcommon/common.js?v=1.0.0"></script>
<script>

    var jgbm;
    $(document).ready(function () {
        jgbm = Common.GetRequest().jgbm; //获取传入的jgbm
        $("#jgbm").val(jgbm);
    });
    //绑定事件
    function save(){
        if (validate()) {
            var jsmc = $.trim($("#jsmc").val());
            var jsms = $.trim($("#jsms").val());
            var jgbm =$.trim($("#jgbm").val());
            $.ajax({
                type: "POST",
                contentType : 'application/json',
                dataType: "json",
                url: "role/save",
                data:  JSON.stringify({
                    'jsmc':jsmc,
                    'jsms':jsms,
                    'jgbm':jgbm
                }),
                success: function (jsonData) {
                    if (jsonData.code == 200) {   //查询成功
                        //window.parent.location.reload(); //刷新父页面
                        /**layer.msg('保存成功!');
                         parent.layer.closeAll();**/
                        LayerWn.showSucAlert('保存成功！');

                        for(var k=0;k<parent.frames.length;k++){
                            if(parent.frames[k].frameElement.src.indexOf("plat-role.html")!=-1)
                                parent.frames[k].queryRoleList();
                        }

                        setTimeout(function(){parent.layer.closeAll()}, 1000);
                    } else {
                        /**layer.alert('保存失败!'+jsonData.msg);
                         parent.layer.closeAll();**/
                        LayerWn.showSucAlert('保存失败！');
                        setTimeout(function(){parent.layer.closeAll()}, 1000);
                    }
                }
            });
        }
    }

    function validate(){
        var jsmc=$.trim($("#jsmc").val());
        if(jsmc==''){
            LayerWn.showAlert('角色名称不能为空');
            return false;
        }
        return true;
    }

</script>
</body>

</html>
